//
//  InputCodeVerifyController.m
//  YongChuanTradingArea
//
//  Created by 李冰 on 2017/9/13.
//  Copyright © 2017年 李冰. All rights reserved.
//

#import "InputCodeVerifyController.h"
#import "StoreListViewController.h" // 店铺列表

@interface InputCodeVerifyController ()
@property (weak, nonatomic) IBOutlet UILabel *storeName;
@property (weak, nonatomic) IBOutlet UITextField *verifyCodeField;

@property (nonatomic, strong) NSString *storeId;

@end

@implementation InputCodeVerifyController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.title = @"消费券验证";
}
- (IBAction)verifyAction:(UIButton *)sender {
    
    NSString *storeId = self.storeId;
    NSString *couponNumber = self.verifyCodeField.text;
    
    if (!storeId || storeId.length == 0)
    {
        [MBProgressHUD showMessageWithOutIcon:@"请选择店铺"];
        return;
    }
    
    if (!couponNumber || couponNumber.length == 0)
    {
        [MBProgressHUD showMessageWithOutIcon:@"请输入验证码"];
        return;
    }
    
    [LBNetworkingInstance requestGET:inputCodeVerify parameters:NSDictionaryOfVariableBindings(storeId,couponNumber) showHUD:YES success:^(id  _Nonnull responseObject, NSInteger code, NSString * _Nonnull message) {
        
        if (code == YCNetworkingStatusCodeSuccess)
        {
            [UIAlertController showWithMessage:@"成功验证1张消费券" controller:self sureAction:^{
                
            }];
            
        }
        
    } failure:^(NSError * _Nonnull err) {
        
    }];
}
- (IBAction)selectStoreAction:(UIButton *)sender {
    
    StoreListViewController *vc = [StoreListViewController new];
    WEAKSELF;
    vc.selectStoreBlock = ^(StoreDetailModel *store) {
        
        weakSelf.storeName.text = store.name;
        weakSelf.storeId = store.ID;
    };
    [self.navigationController pushViewController:vc animated:YES];
}
@end
